# load library
library(tidyverse)
library(afex)
library(lme4)
library(lmerTest)
library(emmeans)
# set up the theme for plot and rainclound plot
# load all the R files in "Utilities/"
tmp <- sapply(list.files('Utilities', "*.R", full.names = TRUE, recursive = TRUE), source)
activationUL <- 2.75
onesample0 <- 0.3 # the staring point of y axis (for one-sample t-tests)
# load data file from localizer scans for univerate analysis
df_loc <- read_csv(fn_loc)
str(df_loc)
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 148 obs. of 8 variables:
## $ ExpCode : num 1 1 1 1 1 1 1 1 1 1 ...
## $ ROI : chr "roi.rh.f20.f-vs-o.label" "roi.rh.f20.f-vs-o.label" "roi.rh.f20.f-vs-o.label" "roi.rh.f20.f-vs-o.label" ...
## $ nVertices : num 207 207 207 207 464 464 464 464 317 317 ...
## $ LabelSize : num 146 146 146 146 320 ...
## $ SubjCode : chr "faceword01_self" "faceword01_self" "faceword01_self" "faceword01_self" ...
## $ Resp : num 0.6185 -0.1185 -0.0554 0.1666 1.8561 ...
## $ Conditions: chr "face" "object" "word" "scrambled" ...
## $ Target : num 1 2 3 4 1 2 3 4 1 2 ...
## - attr(*, "spec")=
## .. cols(
## .. ExpCode = col_double(),
## .. ROI = col_character(),
## .. nVertices = col_double(),
## .. LabelSize = col_double(),
## .. SubjCode = col_character(),
## .. Resp = col_double(),
## .. Conditions = col_character(),
## .. Target = col_double()
## .. )
df_clean_loc <- {
df_loc %>%
mutate(Conditions = factor(Conditions, levels = locOrder)) %>% # convert Conditions to factors
select(ExpCode, ROI, SubjCode, Conditions, Resp)
}
str(df_clean_loc)
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 148 obs. of 5 variables:
## $ ExpCode : num 1 1 1 1 1 1 1 1 1 1 ...
## $ ROI : chr "roi.rh.f20.f-vs-o.label" "roi.rh.f20.f-vs-o.label" "roi.rh.f20.f-vs-o.label" "roi.rh.f20.f-vs-o.label" ...
## $ SubjCode : chr "faceword01_self" "faceword01_self" "faceword01_self" "faceword01_self" ...
## $ Conditions: Factor w/ 4 levels "face","object",..: 1 2 3 4 1 2 3 4 1 2 ...
## $ Resp : num 0.6185 -0.1185 -0.0554 0.1666 1.8561 ...
# load data file from functional scans for univerate analysis
df_univar <- read_csv(fn_univar)
str(df_univar)
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 26640 obs. of 8 variables:
## $ ExpCode : num 1 1 1 1 1 1 1 1 1 1 ...
## $ ROI : chr "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" ...
## $ nVertices : num 636 636 636 636 636 636 636 636 636 636 ...
## $ LabelSize : num 438 438 438 438 438 ...
## $ SubjCode : chr "faceword03_self" "faceword03_self" "faceword03_self" "faceword03_self" ...
## $ Resp : num 0.488 0.732 0.387 1.073 1.187 ...
## $ Conditions: chr "face_intact" "face_exchange" "face_top" "face_bottom" ...
## $ Target : num 1 2 3 4 5 6 7 8 1 2 ...
## - attr(*, "spec")=
## .. cols(
## .. ExpCode = col_double(),
## .. ROI = col_character(),
## .. nVertices = col_double(),
## .. LabelSize = col_double(),
## .. SubjCode = col_character(),
## .. Resp = col_double(),
## .. Conditions = col_character(),
## .. Target = col_double()
## .. )
df_clean_univar <- {
df_univar %>%
separate(Conditions, c("FaceWord", "Layout"), "_") %>% # separate the conditions into two IVs
mutate(# FaceWord = as.factor(FaceWord),
Layout = factor(Layout, levels = layoutOrder), # convert the two IVs to factors
Hemisphere = if_else(grepl("lh", ROI), "left", if_else(grepl("rh", ROI), "right", "NA"))) %>%
select(ExpCode, Hemisphere, ROI, SubjCode, FaceWord, Layout, Resp)
}
str(df_clean_univar)
## Classes 'tbl_df', 'tbl' and 'data.frame': 26640 obs. of 7 variables:
## $ ExpCode : num 1 1 1 1 1 1 1 1 1 1 ...
## $ Hemisphere: chr "left" "left" "left" "left" ...
## $ ROI : chr "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" ...
## $ SubjCode : chr "faceword03_self" "faceword03_self" "faceword03_self" "faceword03_self" ...
## $ FaceWord : chr "face" "face" "face" "face" ...
## $ Layout : Factor w/ 4 levels "intact","exchange",..: 1 2 3 4 1 2 3 4 1 2 ...
## $ Resp : num 0.488 0.732 0.387 1.073 1.187 ...
df_univar_agg <- {
df_clean_univar %>%
group_by(ExpCode, Hemisphere, ROI, SubjCode, FaceWord, Layout) %>%
summarize(meanResp = mean(Resp), Count = n()) %>%
ungroup()
}
str(df_univar_agg)
## Classes 'tbl_df', 'tbl' and 'data.frame': 2664 obs. of 8 variables:
## $ ExpCode : num 1 1 1 1 1 1 1 1 1 1 ...
## $ Hemisphere: chr "left" "left" "left" "left" ...
## $ ROI : chr "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" ...
## $ SubjCode : chr "faceword03_self" "faceword03_self" "faceword03_self" "faceword03_self" ...
## $ FaceWord : chr "face" "face" "face" "face" ...
## $ Layout : Factor w/ 4 levels "intact","exchange",..: 1 2 3 4 1 2 3 4 1 2 ...
## $ meanResp : num 0.869 0.766 0.671 0.651 1.025 ...
## $ Count : int 10 10 10 10 10 10 10 10 10 10 ...
df_mvpa <- read_csv(fn_cosmo)
str(df_mvpa)
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 33300 obs. of 11 variables:
## $ ExpCode : num 1 1 1 1 1 1 1 1 1 1 ...
## $ ROI : chr "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" ...
## $ nVertices : num 636 636 636 636 636 636 636 636 636 636 ...
## $ LabelSize : num 438 438 438 438 438 ...
## $ SubjCode : chr "faceword03_self" "faceword03_self" "faceword03_self" "faceword03_self" ...
## $ ClassifyPair: chr "face_intact-word_intact" "face_intact-word_intact" "face_intact-word_intact" "face_intact-word_intact" ...
## $ Classifier : chr "cosmo_classify_libsvm" "cosmo_classify_libsvm" "cosmo_classify_libsvm" "cosmo_classify_libsvm" ...
## $ Run : num 1 1 2 2 3 3 4 4 5 5 ...
## $ Predicted : num 1 5 5 5 1 1 1 5 5 5 ...
## $ Targets : num 1 5 1 5 1 5 1 5 1 5 ...
## $ ACC : num 1 1 0 1 1 0 1 1 0 1 ...
## - attr(*, "spec")=
## .. cols(
## .. ExpCode = col_double(),
## .. ROI = col_character(),
## .. nVertices = col_double(),
## .. LabelSize = col_double(),
## .. SubjCode = col_character(),
## .. ClassifyPair = col_character(),
## .. Classifier = col_character(),
## .. Run = col_double(),
## .. Predicted = col_double(),
## .. Targets = col_double(),
## .. ACC = col_double()
## .. )
df_clean_mvpa <- {
df_mvpa %>%
select(ExpCode, ROI, SubjCode, ClassifyPair, Predicted, Targets, ACC) %>%
mutate(Hemisphere = if_else(grepl("lh", ROI), "left", if_else(grepl("rh", ROI), "right", "NA")))
}
str(df_clean_mvpa)
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 33300 obs. of 8 variables:
## $ ExpCode : num 1 1 1 1 1 1 1 1 1 1 ...
## $ ROI : chr "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f13.f-vs-o.ffa1.label" ...
## $ SubjCode : chr "faceword03_self" "faceword03_self" "faceword03_self" "faceword03_self" ...
## $ ClassifyPair: chr "face_intact-word_intact" "face_intact-word_intact" "face_intact-word_intact" "face_intact-word_intact" ...
## $ Predicted : num 1 5 5 5 1 1 1 5 5 5 ...
## $ Targets : num 1 5 1 5 1 5 1 5 1 5 ...
## $ ACC : num 1 1 0 1 1 0 1 1 0 1 ...
## $ Hemisphere : chr "left" "left" "left" "left" ...
df_mvpa_acc <- {
df_clean_mvpa %>%
select(-c(Predicted, Targets)) %>% # remove these two columns
group_by(ExpCode, Hemisphere, ROI, SubjCode, ClassifyPair) %>% # divide the data into groups by these columns
summarize(Accuracy = mean(ACC), Count = n()) %>%
ungroup()
}
desc_mvpa_acc <- {
df_mvpa_acc %>%
group_by(ExpCode, Hemisphere, ROI, ClassifyPair) %>%
summarize(emmean = mean(Accuracy), Count = n(), SE = sd(Accuracy)/sqrt(Count)) %>%
mutate(lower.CL = lower_ci(emmean, SE, Count),
upper.CL = upper_ci(emmean, SE, Count)) %>%
ungroup()
}
# obtain from MVPA dataset
roi_info <- {
df_mvpa %>%
select(ExpCode, ROI, SubjCode, nVertices, LabelSize) %>%
distinct()
}
# labels used in the analyses
label_list <- unique(roi_info$ROI)
# logical (which condition these labels are)
isLeft <- grepl("lh", label_list) # is left hemisphere label
isRight <- grepl("rh", label_list) # is right hemisphere label
isFFA1 <- grepl("ffa1", label_list) # is FFA1
isFFA2 <- grepl("ffa2", label_list) # is FFA2
isVWFA <- grepl("w-vs-o", label_list) # is visual word form area
isFFA <- !isFFA1 & !isFFA2 & !isVWFA
# labels for each ROI
label_lFFA <- label_list[isLeft & isFFA] # the labels for left FFA
label_rFFA <- label_list[isRight & isFFA] # the labels for right FFA
label_lFFA1 <- label_list[isLeft & isFFA1] # the labels for left FFA1
label_rFFA1 <- label_list[isRight & isFFA1] # the labels for left FFA1
label_lFFA2 <- label_list[isLeft & isFFA2] # the labels for left FFA2
label_rFFA2 <- label_list[isRight & isFFA2] # the labels for left FFA1
label_lVWFA <- label_list[isVWFA] # the labels for visual word form area
# all the labels available in this analysis
# label_list
desc_mvpa_acc %>%
select(ExpCode, ROI, Count) %>%
distinct() %>%
spread(ROI, Count)
df_loc_E1 <- {
df_clean_loc %>%
filter(ExpCode == 1) %>%
mutate(SubjCode = as.factor(SubjCode))
}
# nlevels(df_loc_E1$SubjCode) # number of subjects
The ROI (label) used for this analysis is roi.rh.f20.f-vs-o.label.
anova_loc_E1 <- aov_4(Resp ~ Conditions + (Conditions | SubjCode), data = df_loc_E1)
anova_loc_E1
## Anova Table (Type 3 tests)
##
## Response: Resp
## Effect df MSE F ges p.value
## 1 Conditions 2.09, 35.56 0.10 68.78 *** .44 <.0001
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_loc_anova_E1 <- emmeans(anova_loc_E1, ~ Conditions)
emm_loc_anova_E1
## Conditions emmean SE df lower.CL upper.CL
## face 2.00 0.121 25.8 1.753 2.25
## object 1.18 0.121 25.8 0.933 1.43
## word 1.13 0.121 25.8 0.879 1.37
## scrambled 0.80 0.121 25.8 0.552 1.05
##
## Warning: EMMs are biased unless design is perfectly balanced
## Confidence level used: 0.95
contrast(emm_loc_anova_E1, "pairwise")
## contrast estimate SE df t.ratio p.value
## face - object 0.8198 0.0871 51 9.412 <.0001
## face - word 0.8738 0.0871 51 10.032 <.0001
## face - scrambled 1.2004 0.0871 51 13.782 <.0001
## object - word 0.0539 0.0871 51 0.619 0.9255
## object - scrambled 0.3806 0.0871 51 4.369 0.0003
## word - scrambled 0.3266 0.0871 51 3.750 0.0025
##
## P value adjustment: tukey method for comparing a family of 4 estimates
lmm_loc_E1 <- lmer(Resp ~ Conditions + (1 | SubjCode), data = df_loc_E1)
summary(lmm_loc_E1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Resp ~ Conditions + (1 | SubjCode)
## Data: df_loc_E1
##
## REML criterion at convergence: 64.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.58483 -0.57796 0.07962 0.58844 1.71453
##
## Random effects:
## Groups Name Variance Std.Dev.
## SubjCode (Intercept) 0.19325 0.4396
## Residual 0.06828 0.2613
## Number of obs: 72, groups: SubjCode, 18
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.0006 0.1205 25.7772 16.597 2.81e-15 ***
## Conditionsobject -0.8198 0.0871 51.0000 -9.412 9.76e-13 ***
## Conditionsword -0.8738 0.0871 51.0000 -10.032 1.16e-13 ***
## Conditionsscrambled -1.2004 0.0871 51.0000 -13.782 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cndtnsb Cndtnsw
## Condtnsbjct -0.361
## Conditnswrd -0.361 0.500
## Cndtnsscrmb -0.361 0.500 0.500
emm_loc_lmm_E1 <- emmeans(lmm_loc_E1, ~ Conditions)
emm_loc_lmm_E1
## Conditions emmean SE df lower.CL upper.CL
## face 2.00 0.121 25.8 1.753 2.25
## object 1.18 0.121 25.8 0.933 1.43
## word 1.13 0.121 25.8 0.879 1.37
## scrambled 0.80 0.121 25.8 0.552 1.05
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
contrast(emm_loc_lmm_E1, "pairwise")
## contrast estimate SE df t.ratio p.value
## face - object 0.8198 0.0871 51 9.412 <.0001
## face - word 0.8738 0.0871 51 10.032 <.0001
## face - scrambled 1.2004 0.0871 51 13.782 <.0001
## object - word 0.0539 0.0871 51 0.619 0.9255
## object - scrambled 0.3806 0.0871 51 4.369 0.0003
## word - scrambled 0.3266 0.0871 51 3.750 0.0025
##
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 4 estimates
plot_loc_E1 <- {
ggplot(data = as.data.frame(emm_loc_anova_E1), aes(y = emmean, x = Conditions)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(0, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Neural Responses") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_loc_E1
# only keep data of E1
df_univar_E1 <- {
df_clean_univar %>%
filter(ExpCode == 1) %>%
mutate(FaceWord = factor(FaceWord, levels = facewordOrder),
SubjCode = as.factor(SubjCode))
}
df_univar_agg_E1 <- {
df_univar_agg %>%
filter(ExpCode == 1) %>%
mutate(FaceWord = factor(FaceWord, levels = facewordOrder),
SubjCode = as.factor(SubjCode))
}
# only keep data of E1
df_mvpa_E1 <- {
df_clean_mvpa %>%
filter(ExpCode == 1) %>%
mutate(ClassifyPair = factor(ClassifyPair, levels = pairOrder_E1),
SubjCode = as.factor(SubjCode))
}
df_mvpa_acc_E1 <- {
df_mvpa_acc %>%
filter(ExpCode == 1) %>%
mutate(ClassifyPair = factor(ClassifyPair, levels = pairOrder_E1),
SubjCode = as.factor(SubjCode))
}
desc_mvpa_acc_E1 <- {
desc_mvpa_acc %>%
filter(ExpCode == 1) %>%
mutate(ClassifyPair = factor(ClassifyPair, levels = pairOrder_E1)) %>%
arrange(ExpCode, Hemisphere, ROI, ClassifyPair)
}
label_lFFA_E1 <- label_lFFA[1] # "roi.lh.f20.f-vs-o.label" "roi.lh.f40.f-vs-o.label"
label_rFFA_E1 <- label_rFFA[1] # "roi.rh.f20.f-vs-o.label" "roi.rh.f40.f-vs-o.label"
label_FFA_E1 <- c(label_lFFA_E1, label_rFFA_E1)
The label used for left FFA in Experiment 1 is roi.lh.f20.f-vs-o.label. The label used for right FFA in Experiment 1 is roi.rh.f20.f-vs-o.label.
# only keep data for these two labels
df_univar_E1_FFA <- filter(df_univar_E1, ROI %in% label_FFA_E1)
df_univar_agg_E1_FFA <- filter(df_univar_agg_E1, ROI %in% label_FFA_E1)
df_mvpa_E1_FFA <- filter(df_mvpa_E1, ROI %in% label_FFA_E1)
df_mvpa_acc_E1_FFA <- filter(df_mvpa_acc_E1, ROI %in% label_FFA_E1)
desc_mvpa_acc_E1_FFA <- filter(desc_mvpa_acc_E1, ROI %in% label_FFA_E1)
# subjects used for each hemisphere
# unique(as.character((df_univar_agg_E1_FFA %>% filter(ROI == label_rFFA_E1))$SubjCode))
desc_mvpa_acc_E1_FFA %>%
select(ExpCode, ROI, Count) %>%
distinct()
anova_E1_lFFA <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E1_FFA, ROI == label_lFFA_E1))
anova_E1_lFFA
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 12 0.11 2.38 .02 .15
## 2 Layout 2.39, 28.63 0.02 6.75 ** .03 .003
## 3 FaceWord:Layout 2.36, 28.31 0.04 0.54 .005 .62
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E1_lFFA <- emmeans(anova_E1_lFFA, ~ FaceWord * Layout)
emm_anova_E1_lFFA %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E1_lFFA, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## face - word 0.101 0.0655 12 1.541 0.1492
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E1_lFFA, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.0248 0.037 36 0.670 0.9078
## intact - top 0.1547 0.037 36 4.186 0.0010
## intact - bottom 0.0654 0.037 36 1.769 0.3046
## exchange - top 0.1300 0.037 36 3.516 0.0063
## exchange - bottom 0.0406 0.037 36 1.099 0.6924
## top - bottom -0.0893 0.037 36 -2.417 0.0918
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E1_lFFA, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . face - word 0.14538 0.0902 34.1 1.612 0.1162
## exchange . face - word 0.08849 0.0902 34.1 0.981 0.3334
## top . face - word 0.13819 0.0902 34.1 1.532 0.1347
## bottom . face - word 0.03151 0.0902 34.1 0.349 0.7290
## . face intact - exchange 0.05320 0.0627 65.9 0.848 0.3993
## . face intact - top 0.15830 0.0627 65.9 2.525 0.0140
## . face intact - bottom 0.12231 0.0627 65.9 1.951 0.0553
## . face exchange - top 0.10510 0.0627 65.9 1.676 0.0984
## . face exchange - bottom 0.06911 0.0627 65.9 1.102 0.2744
## . face top - bottom -0.03599 0.0627 65.9 -0.574 0.5679
## . word intact - exchange -0.00369 0.0627 65.9 -0.059 0.9533
## . word intact - top 0.15112 0.0627 65.9 2.410 0.0187
## . word intact - bottom 0.00844 0.0627 65.9 0.135 0.8933
## . word exchange - top 0.15480 0.0627 65.9 2.469 0.0162
## . word exchange - bottom 0.01213 0.0627 65.9 0.193 0.8472
## . word top - bottom -0.14267 0.0627 65.9 -2.275 0.0261
# contrast(emm_uni_anova_E1, interaction = "pairwise") # , adjust = "none"
anova_E1_rFFA <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E1_FFA, ROI == label_rFFA_E1))
anova_E1_rFFA
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 17 0.16 16.05 *** .06 .0009
## 2 Layout 2.41, 40.92 0.03 7.61 *** .01 .0008
## 3 FaceWord:Layout 1.90, 32.23 0.06 2.03 .005 .15
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E1_rFFA <- emmeans(anova_E1_rFFA, ~ FaceWord * Layout)
emm_anova_E1_rFFA %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E1_rFFA, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## face - word 0.27 0.0673 17 4.006 0.0009
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E1_rFFA, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.1366 0.0378 51 3.619 0.0037
## intact - top 0.1684 0.0378 51 4.459 0.0003
## intact - bottom 0.1201 0.0378 51 3.182 0.0129
## exchange - top 0.0317 0.0378 51 0.840 0.8350
## exchange - bottom -0.0165 0.0378 51 -0.437 0.9718
## top - bottom -0.0482 0.0378 51 -1.277 0.5813
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E1_rFFA, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . face - word 0.39517 0.0865 40.6 4.569 <.0001
## exchange . face - word 0.24291 0.0865 40.6 2.808 0.0076
## top . face - word 0.18464 0.0865 40.6 2.135 0.0389
## bottom . face - word 0.25643 0.0865 40.6 2.965 0.0051
## . face intact - exchange 0.21277 0.0582 99.5 3.655 0.0004
## . face intact - top 0.27363 0.0582 99.5 4.700 <.0001
## . face intact - bottom 0.18950 0.0582 99.5 3.255 0.0016
## . face exchange - top 0.06086 0.0582 99.5 1.045 0.2984
## . face exchange - bottom -0.02327 0.0582 99.5 -0.400 0.6903
## . face top - bottom -0.08413 0.0582 99.5 -1.445 0.1516
## . word intact - exchange 0.06051 0.0582 99.5 1.039 0.3012
## . word intact - top 0.06309 0.0582 99.5 1.084 0.2811
## . word intact - bottom 0.05076 0.0582 99.5 0.872 0.3854
## . word exchange - top 0.00259 0.0582 99.5 0.044 0.9647
## . word exchange - bottom -0.00974 0.0582 99.5 -0.167 0.8674
## . word top - bottom -0.01233 0.0582 99.5 -0.212 0.8327
# contrast(emm_uni_anova_E1, interaction = "pairwise") # , adjust = "none"
# add the column of Hemisphere
nRow_E1 <-nrow(as.data.frame(emm_anova_E1_lFFA))
Hemisphere <- c(rep("left", nRow_E1), rep("right", nRow_E1))
desp_uni_E1_FFA <- cbind(Hemisphere, rbind(as.data.frame(emm_anova_E1_lFFA), as.data.frame(emm_anova_E1_rFFA)))
plot_uni_E1_FFA <- {
ggplot(data = desp_uni_E1_FFA, aes(y = emmean, x = FaceWord, fill = Layout)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(0, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Beta values") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_uni_E1_FFA
df_mvpa_agg_E1_FFA <- {
df_mvpa_acc_E1_FFA %>%
spread(ClassifyPair, Accuracy) %>% # change to table (each row is one subject)
select(-c(ExpCode, ROI, SubjCode, Count)) # remove these columns
}
df_mvpa_agg_E1_FFA %>%
filter(Hemisphere == "left") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## face_intact-word_intact face_intact-face_exchange
## statistic 4.187461 0.4505106
## parameter 12 12
## p.value 0.0006298376 0.3301869
## conf.int Numeric,2 Numeric,2
## estimate 0.6961538 0.5153846
## null.value 0.5 0.5
## stderr 0.04684314 0.03414928
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## face_top-face_bottom word_intact-word_exchange
## statistic 1.877304 0.875481
## parameter 12 12
## p.value 0.04249586 0.1992487
## conf.int Numeric,2 Numeric,2
## estimate 0.5423077 0.5307692
## null.value 0.5 0.5
## stderr 0.0225364 0.03514551
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## word_top-word_bottom
## statistic 0.3526363
## parameter 12
## p.value 0.3652387
## conf.int Numeric,2
## estimate 0.5076923
## null.value 0.5
## stderr 0.02181372
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
df_mvpa_agg_E1_FFA %>%
filter(Hemisphere == "right") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## face_intact-word_intact face_intact-face_exchange
## statistic 7.652413 1.624171
## parameter 17 17
## p.value 3.323434e-07 0.06136725
## conf.int Numeric,2 Numeric,2
## estimate 0.7277778 0.55
## null.value 0.5 0.5
## stderr 0.02976548 0.03078494
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## face_top-face_bottom word_intact-word_exchange
## statistic 2.415069 -0.2203893
## parameter 17 17
## p.value 0.01364066 0.5859035
## conf.int Numeric,2 Numeric,2
## estimate 0.5861111 0.4944444
## null.value 0.5 0.5
## stderr 0.03565575 0.02520792
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## word_top-word_bottom
## statistic -1.38675
## parameter 17
## p.value 0.9082826
## conf.int Numeric,2
## estimate 0.4583333
## null.value 0.5
## stderr 0.03004626
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
plot_mvpa_E1_FFA <- {
ggplot(data = desc_mvpa_acc_E1_FFA, aes(y = emmean, x = ClassifyPair)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
geom_hline(yintercept = c(0.5, 1), linetype = 5, alpha = 0.5) + # add the line for 0.5 and 1 (y)
scale_y_continuous(expand= c(0, 0), limits = c(0, 1.1), breaks = seq(0, 1, .25)) + # remove the space between columns and x axis
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) + # show x labels in two rows
labs(title = "", x = "Stimuli", y = "Accuracy") + # set the names for main, x and y axises Subjective Responses for E205
geom_text(label = c("***", "", "*", "", "", "***", "*", "*", "", ""), color = c(rep("red", 6), "blue", rep("red", 3)), size = 10, nudge_y = 0.15) + # add starts to the significant columns
general_theme
# theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
}
plot_mvpa_E1_FFA
label_lFFA1_E1 <- label_lFFA1[1] # "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f20.f-vs-o.ffa1.label"
label_rFFA1_E1 <- label_rFFA1[1] # "roi.rh.f13.f-vs-o.ffa1.label"
label_FFA1_E1 <- c(label_lFFA1_E1, label_rFFA1_E1)
The label used for left FFA1 in Experiment 1 is roi.lh.f13.f-vs-o.ffa1.label. The label used for right FFA1 in Experiment 1 is roi.rh.f13.f-vs-o.ffa1.label.
# only keep data for these two labels
df_univar_E1_FFA1 <- filter(df_univar_E1, ROI %in% label_FFA1_E1)
df_univar_agg_E1_FFA1 <- filter(df_univar_agg_E1, ROI %in% label_FFA1_E1)
df_mvpa_E1_FFA1 <- filter(df_mvpa_E1, ROI %in% label_FFA1_E1)
df_mvpa_acc_E1_FFA1 <- filter(df_mvpa_acc_E1, ROI %in% label_FFA1_E1)
desc_mvpa_acc_E1_FFA1 <- filter(desc_mvpa_acc_E1, ROI %in% label_FFA1_E1)
# subjects used for each hemisphere
# unique(as.character((df_univar_agg_E1_FFA1 %>% filter(ROI == label_rFFA1_E1))$SubjCode))
desc_mvpa_acc_E1_FFA1 %>%
select(ExpCode, ROI, Count) %>%
distinct()
anova_E1_lFFA1 <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E1_FFA1, ROI == label_lFFA1_E1))
anova_E1_lFFA1
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 12 0.19 8.80 * .07 .01
## 2 Layout 2.12, 25.40 0.03 13.66 *** .04 <.0001
## 3 FaceWord:Layout 2.07, 24.89 0.04 1.60 .006 .22
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E1_lFFA1 <- emmeans(anova_E1_lFFA1, ~ FaceWord * Layout)
emm_anova_E1_lFFA1 %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E1_lFFA1, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## face - word 0.251 0.0846 12 2.966 0.0118
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E1_lFFA1, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.0393 0.0403 36 0.974 0.7648
## intact - top 0.2362 0.0403 36 5.856 <.0001
## intact - bottom 0.1337 0.0403 36 3.313 0.0109
## exchange - top 0.1969 0.0403 36 4.881 0.0001
## exchange - bottom 0.0943 0.0403 36 2.338 0.1081
## top - bottom -0.1026 0.0403 36 -2.543 0.0701
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E1_lFFA1, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . face - word 0.3271 0.1010 23.0 3.237 0.0036
## exchange . face - word 0.1923 0.1010 23.0 1.903 0.0697
## top . face - word 0.3132 0.1010 23.0 3.100 0.0050
## bottom . face - word 0.1709 0.1010 23.0 1.691 0.1043
## . face intact - exchange 0.1067 0.0605 71.1 1.762 0.0823
## . face intact - top 0.2432 0.0605 71.1 4.016 0.0001
## . face intact - bottom 0.2117 0.0605 71.1 3.497 0.0008
## . face exchange - top 0.1365 0.0605 71.1 2.254 0.0273
## . face exchange - bottom 0.1050 0.0605 71.1 1.735 0.0871
## . face top - bottom -0.0314 0.0605 71.1 -0.519 0.6053
## . word intact - exchange -0.0281 0.0605 71.1 -0.464 0.6441
## . word intact - top 0.2293 0.0605 71.1 3.788 0.0003
## . word intact - bottom 0.0556 0.0605 71.1 0.918 0.3618
## . word exchange - top 0.2574 0.0605 71.1 4.252 0.0001
## . word exchange - bottom 0.0837 0.0605 71.1 1.382 0.1714
## . word top - bottom -0.1738 0.0605 71.1 -2.870 0.0054
# contrast(emm_uni_anova_E1, interaction = "pairwise") # , adjust = "none"
anova_E1_rFFA1 <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E1_FFA1, ROI == label_rFFA1_E1))
anova_E1_rFFA1
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 17 0.18 22.45 *** .11 .0002
## 2 Layout 2.01, 34.10 0.05 3.38 * .01 .05
## 3 FaceWord:Layout 2.33, 39.64 0.07 2.95 + .01 .06
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E1_rFFA1 <- emmeans(anova_E1_rFFA1, ~ FaceWord * Layout)
emm_anova_E1_rFFA1 %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E1_rFFA1, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## face - word 0.339 0.0716 17 4.739 0.0002
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E1_rFFA1, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.1066 0.045 51 2.369 0.0963
## intact - top 0.1360 0.045 51 3.022 0.0198
## intact - bottom 0.0876 0.045 51 1.947 0.2217
## exchange - top 0.0294 0.045 51 0.653 0.9139
## exchange - bottom -0.0190 0.045 51 -0.422 0.9745
## top - bottom -0.0484 0.045 51 -1.075 0.7062
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E1_rFFA1, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . face - word 0.52123 0.0971 46.6 5.369 <.0001
## exchange . face - word 0.27597 0.0971 46.6 2.843 0.0066
## top . face - word 0.22205 0.0971 46.6 2.287 0.0268
## bottom . face - word 0.33728 0.0971 46.6 3.474 0.0011
## . face intact - exchange 0.22919 0.0700 99.0 3.276 0.0014
## . face intact - top 0.28555 0.0700 99.0 4.082 0.0001
## . face intact - bottom 0.17956 0.0700 99.0 2.567 0.0118
## . face exchange - top 0.05636 0.0700 99.0 0.806 0.4223
## . face exchange - bottom -0.04962 0.0700 99.0 -0.709 0.4797
## . face top - bottom -0.10598 0.0700 99.0 -1.515 0.1329
## . word intact - exchange -0.01607 0.0700 99.0 -0.230 0.8188
## . word intact - top -0.01364 0.0700 99.0 -0.195 0.8459
## . word intact - bottom -0.00438 0.0700 99.0 -0.063 0.9502
## . word exchange - top 0.00243 0.0700 99.0 0.035 0.9723
## . word exchange - bottom 0.01169 0.0700 99.0 0.167 0.8676
## . word top - bottom 0.00926 0.0700 99.0 0.132 0.8950
# contrast(emm_uni_anova_E1, interaction = "pairwise") # , adjust = "none"
# add the column of Hemisphere
nRow_E1 <-nrow(as.data.frame(emm_anova_E1_lFFA1))
Hemisphere <- c(rep("left", nRow_E1), rep("right", nRow_E1))
desp_uni_E1_FFA1 <- cbind(Hemisphere, rbind(as.data.frame(emm_anova_E1_lFFA1), as.data.frame(emm_anova_E1_rFFA1)))
plot_uni_E1_FFA1 <- {
ggplot(data = desp_uni_E1_FFA1, aes(y = emmean, x = FaceWord, fill = Layout)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(0, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Beta values") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_uni_E1_FFA1
df_mvpa_agg_E1_FFA1 <- {
df_mvpa_acc_E1_FFA1 %>%
spread(ClassifyPair, Accuracy) %>% # change to table (each row is one subject)
select(-c(ExpCode, ROI, SubjCode, Count)) # remove these columns
}
df_mvpa_agg_E1_FFA1 %>%
filter(Hemisphere == "left") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## face_intact-word_intact face_intact-face_exchange
## statistic 4.450099 -1.615634
## parameter 12 12
## p.value 0.0003963662 0.9339285
## conf.int Numeric,2 Numeric,2
## estimate 0.7461538 0.4538462
## null.value 0.5 0.5
## stderr 0.05531424 0.02856703
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## face_top-face_bottom word_intact-word_exchange
## statistic 2.444444 0.7427814
## parameter 12 12
## p.value 0.01545283 0.2359526
## conf.int Numeric,2 Numeric,2
## estimate 0.5846154 0.5307692
## null.value 0.5 0.5
## stderr 0.03461538 0.04142434
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## word_top-word_bottom
## statistic 1.469937
## parameter 12
## p.value 0.08365259
## conf.int Numeric,2
## estimate 0.5423077
## null.value 0.5
## stderr 0.02878198
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
df_mvpa_agg_E1_FFA1 %>%
filter(Hemisphere == "right") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## face_intact-word_intact face_intact-face_exchange
## statistic 8.349812 0.8838768
## parameter 17 17
## p.value 1.014122e-07 0.1945461
## conf.int Numeric,2 Numeric,2
## estimate 0.8027778 0.5305556
## null.value 0.5 0.5
## stderr 0.03626163 0.03456993
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## face_top-face_bottom word_intact-word_exchange
## statistic 4.101923 -1
## parameter 17 17
## p.value 0.0003718101 0.8343336
## conf.int Numeric,2 Numeric,2
## estimate 0.6444444 0.475
## null.value 0.5 0.5
## stderr 0.03521384 0.025
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## word_top-word_bottom
## statistic -0.6092446
## parameter 17
## p.value 0.7247908
## conf.int Numeric,2
## estimate 0.4861111
## null.value 0.5
## stderr 0.0227969
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
plot_mvpa_E1_FFA1 <- {
ggplot(data = desc_mvpa_acc_E1_FFA1, aes(y = emmean, x = ClassifyPair)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
geom_hline(yintercept = c(0.5, 1), linetype = 5, alpha = 0.5) + # add the line for 0.5 and 1 (y)
scale_y_continuous(expand= c(0, 0), limits = c(0, 1.1), breaks = seq(0, 1, .25)) + # remove the space between columns and x axis
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) + # show x labels in two rows
labs(title = "", x = "Stimuli", y = "Accuracy") + # set the names for main, x and y axises Subjective Responses for E205
geom_text(label = c("***", "", "*", "", "*", "***", "", "***", "", ""), color = c(rep("red", 4), "blue", rep("red", 5)), size = 10, nudge_y = 0.15) + # add starts to the significant columns
general_theme
# theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
}
plot_mvpa_E1_FFA1
label_lFFA2_E1 <- label_lFFA2[1] # "roi.lh.f13.f-vs-o.ffa2.label"
label_rFFA2_E1 <- label_rFFA2[1] # "roi.rh.f20.f-vs-o.ffa2.label" "roi.rh.f40.f-vs-o.ffa2.label"
label_FFA2_E1 <- c(label_lFFA2_E1, label_rFFA2_E1)
The label used for left FFA2 in Experiment 1 is roi.lh.f13.f-vs-o.ffa2.label. The label used for right FFA2 in Experiment 1 is roi.rh.f20.f-vs-o.ffa2.label.
# only keep data for these two labels
df_univar_E1_FFA2 <- filter(df_univar_E1, ROI %in% label_FFA2_E1)
df_univar_agg_E1_FFA2 <- filter(df_univar_agg_E1, ROI %in% label_FFA2_E1)
df_mvpa_E1_FFA2 <- filter(df_mvpa_E1, ROI %in% label_FFA2_E1)
df_mvpa_acc_E1_FFA2 <- filter(df_mvpa_acc_E1, ROI %in% label_FFA2_E1)
desc_mvpa_acc_E1_FFA2 <- filter(desc_mvpa_acc_E1, ROI %in% label_FFA2_E1)
# subjects used for each hemisphere
# unique(as.character((df_univar_agg_E1_FFA2 %>% filter(ROI == label_lFFA2_E1))$SubjCode))
desc_mvpa_acc_E1_FFA2 %>%
select(ExpCode, ROI, Count) %>%
distinct()
anova_E1_lFFA2 <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E1_FFA2, ROI == label_lFFA2_E1))
anova_E1_lFFA2
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 14 0.08 0.84 .006 .37
## 2 Layout 2.51, 35.14 0.02 5.30 ** .02 .006
## 3 FaceWord:Layout 2.71, 37.90 0.03 0.54 .004 .64
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E1_lFFA2 <- emmeans(anova_E1_lFFA2, ~ FaceWord * Layout)
emm_anova_E1_lFFA2 %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E1_lFFA2, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## face - word 0.0488 0.0532 14 0.918 0.3743
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E1_lFFA2, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.02101 0.0337 42 0.623 0.9243
## intact - top 0.12372 0.0337 42 3.666 0.0037
## intact - bottom 0.02866 0.0337 42 0.849 0.8306
## exchange - top 0.10271 0.0337 42 3.043 0.0202
## exchange - bottom 0.00765 0.0337 42 0.227 0.9958
## top - bottom -0.09506 0.0337 42 -2.817 0.0357
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E1_lFFA2, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . face - word 0.06989 0.0746 41.3 0.937 0.3542
## exchange . face - word 0.03263 0.0746 41.3 0.437 0.6641
## top . face - word 0.09731 0.0746 41.3 1.305 0.1993
## bottom . face - word -0.00465 0.0746 41.3 -0.062 0.9506
## . face intact - exchange 0.03964 0.0544 79.7 0.728 0.4687
## . face intact - top 0.11000 0.0544 79.7 2.021 0.0467
## . face intact - bottom 0.06593 0.0544 79.7 1.211 0.2295
## . face exchange - top 0.07037 0.0544 79.7 1.293 0.1999
## . face exchange - bottom 0.02629 0.0544 79.7 0.483 0.6305
## . face top - bottom -0.04408 0.0544 79.7 -0.810 0.4205
## . word intact - exchange 0.00238 0.0544 79.7 0.044 0.9652
## . word intact - top 0.13743 0.0544 79.7 2.524 0.0136
## . word intact - bottom -0.00861 0.0544 79.7 -0.158 0.8748
## . word exchange - top 0.13505 0.0544 79.7 2.481 0.0152
## . word exchange - bottom -0.01099 0.0544 79.7 -0.202 0.8405
## . word top - bottom -0.14604 0.0544 79.7 -2.682 0.0089
# contrast(emm_uni_anova_E1, interaction = "pairwise") # , adjust = "none"
anova_E1_rFFA2 <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E1_FFA2, ROI == label_rFFA2_E1))
anova_E1_rFFA2
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 15 0.16 16.84 *** .08 .0009
## 2 Layout 2.56, 38.44 0.03 6.57 ** .02 .002
## 3 FaceWord:Layout 2.00, 30.04 0.04 2.76 + .007 .08
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E1_rFFA2 <- emmeans(anova_E1_rFFA2, ~ FaceWord * Layout)
emm_anova_E1_rFFA2 %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E1_rFFA2, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## face - word 0.287 0.07 15 4.103 0.0009
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E1_rFFA2, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.1590 0.0393 45 4.047 0.0011
## intact - top 0.1360 0.0393 45 3.462 0.0063
## intact - bottom 0.1227 0.0393 45 3.122 0.0160
## exchange - top -0.0230 0.0393 45 -0.585 0.9361
## exchange - bottom -0.0363 0.0393 45 -0.924 0.7921
## top - bottom -0.0133 0.0393 45 -0.339 0.9864
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E1_rFFA2, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . face - word 0.41334 0.0852 30.6 4.852 <.0001
## exchange . face - word 0.21788 0.0852 30.6 2.557 0.0157
## top . face - word 0.21522 0.0852 30.6 2.526 0.0169
## bottom . face - word 0.30207 0.0852 30.6 3.546 0.0013
## . face intact - exchange 0.25671 0.0558 90.0 4.597 <.0001
## . face intact - top 0.23505 0.0558 90.0 4.209 0.0001
## . face intact - bottom 0.17831 0.0558 90.0 3.193 0.0019
## . face exchange - top -0.02166 0.0558 90.0 -0.388 0.6991
## . face exchange - bottom -0.07840 0.0558 90.0 -1.404 0.1638
## . face top - bottom -0.05675 0.0558 90.0 -1.016 0.3123
## . word intact - exchange 0.06125 0.0558 90.0 1.097 0.2756
## . word intact - top 0.03694 0.0558 90.0 0.661 0.5100
## . word intact - bottom 0.06704 0.0558 90.0 1.200 0.2331
## . word exchange - top -0.02431 0.0558 90.0 -0.435 0.6643
## . word exchange - bottom 0.00579 0.0558 90.0 0.104 0.9177
## . word top - bottom 0.03010 0.0558 90.0 0.539 0.5912
# contrast(emm_uni_anova_E1, interaction = "pairwise") # , adjust = "none"
# add the column of Hemisphere
nRow_E1 <-nrow(as.data.frame(emm_anova_E1_lFFA2))
Hemisphere <- c(rep("left", nRow_E1), rep("right", nRow_E1))
desp_uni_E1_FFA2 <- cbind(Hemisphere, rbind(as.data.frame(emm_anova_E1_lFFA2), as.data.frame(emm_anova_E1_rFFA2)))
plot_uni_E1_FFA2 <- {
ggplot(data = desp_uni_E1_FFA2, aes(y = emmean, x = FaceWord, fill = Layout)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(0, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Beta values") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_uni_E1_FFA2
df_mvpa_agg_E1_FFA2 <- {
df_mvpa_acc_E1_FFA2 %>%
spread(ClassifyPair, Accuracy) %>% # change to table (each row is one subject)
select(-c(ExpCode, ROI, SubjCode, Count)) # remove these columns
}
df_mvpa_agg_E1_FFA2 %>%
filter(Hemisphere == "left") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## face_intact-word_intact face_intact-face_exchange
## statistic 5.479596 1.318795
## parameter 14 14
## p.value 4.056968e-05 0.104202
## conf.int Numeric,2 Numeric,2
## estimate 0.7266667 0.5366667
## null.value 0.5 0.5
## stderr 0.04136558 0.02780316
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## face_top-face_bottom word_intact-word_exchange
## statistic 2.415229 0.7697249
## parameter 14 14
## p.value 0.01499046 0.2271277
## conf.int Numeric,2 Numeric,2
## estimate 0.55 0.53
## null.value 0.5 0.5
## stderr 0.02070197 0.03897496
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## word_top-word_bottom
## statistic -1.287593
## parameter 14
## p.value 0.8906168
## conf.int Numeric,2
## estimate 0.47
## null.value 0.5
## stderr 0.02329929
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
df_mvpa_agg_E1_FFA2 %>%
filter(Hemisphere == "right") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## face_intact-word_intact face_intact-face_exchange
## statistic 6.902685 3.263767
## parameter 15 15
## p.value 2.519153e-06 0.002616777
## conf.int Numeric,2 Numeric,2
## estimate 0.725 0.5875
## null.value 0.5 0.5
## stderr 0.03259601 0.02680951
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## face_top-face_bottom word_intact-word_exchange
## statistic 0.7644708 1.485041
## parameter 15 15
## p.value 0.2282227 0.07912206
## conf.int Numeric,2 Numeric,2
## estimate 0.528125 0.534375
## null.value 0.5 0.5
## stderr 0.03679016 0.02314751
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## word_top-word_bottom
## statistic -0.5816751
## parameter 15
## p.value 0.7152876
## conf.int Numeric,2
## estimate 0.48125
## null.value 0.5
## stderr 0.03223449
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
plot_mvpa_E1_FFA2 <- {
ggplot(data = desc_mvpa_acc_E1_FFA2, aes(y = emmean, x = ClassifyPair)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
geom_hline(yintercept = c(0.5, 1), linetype = 5, alpha = 0.5) + # add the line for 0.5 and 1 (y)
scale_y_continuous(expand= c(0, 0), limits = c(0, 1.1), breaks = seq(0, 1, .25)) + # remove the space between columns and x axis
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) + # show x labels in two rows
labs(title = "", x = "Stimuli", y = "Accuracy") + # set the names for main, x and y axises Subjective Responses for E205
geom_text(label = c("***", "", "*", "", "", "***", "**", "", "*", ""), color = c(rep("red", 8), "blue", rep("red", 1)), size = 10, nudge_y = 0.15) + # add starts to the significant columns
general_theme
# theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
}
plot_mvpa_E1_FFA2
label_VWFA_E1 <- label_lVWFA[1] # "roi.lh.f13.w-vs-o.label"
The label used for (left) VWFA in Experiment 1 is roi.lh.f13.w-vs-o.label.
# only keep data for these two labels
df_univar_E1_VWFA <- filter(df_univar_E1, ROI %in% label_VWFA_E1)
df_univar_agg_E1_VWFA <- filter(df_univar_agg_E1, ROI %in% label_VWFA_E1)
df_mvpa_E1_VWFA <- filter(df_mvpa_E1, ROI %in% label_VWFA_E1)
df_mvpa_acc_E1_VWFA <- filter(df_mvpa_acc_E1, ROI %in% label_VWFA_E1)
desc_mvpa_acc_E1_VWFA <- filter(desc_mvpa_acc_E1, ROI %in% label_VWFA_E1)
# subjects used for each hemisphere
# unique(as.character((df_univar_agg_E1_VWFA %>% filter(ROI == label_VWFA_E1))$SubjCode))
desc_mvpa_acc_E1_VWFA %>%
select(ExpCode, ROI, Count) %>%
distinct()
anova_E1_VWFA <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E1_VWFA, ROI == label_VWFA_E1))
anova_E1_VWFA
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 17 0.13 55.87 *** .19 <.0001
## 2 Layout 2.75, 46.73 0.03 2.47 + .007 .08
## 3 FaceWord:Layout 2.48, 42.20 0.03 8.79 *** .02 .0003
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E1_VWFA <- emmeans(anova_E1_VWFA, ~ FaceWord * Layout)
emm_anova_E1_VWFA %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E1_VWFA, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## face - word -0.449 0.0601 17 -7.474 <.0001
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E1_VWFA, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.0172 0.0404 51 0.425 0.9739
## intact - top 0.0965 0.0404 51 2.390 0.0919
## intact - bottom 0.0692 0.0404 51 1.712 0.3280
## exchange - top 0.0794 0.0404 51 1.965 0.2147
## exchange - bottom 0.0520 0.0404 51 1.287 0.5751
## top - bottom -0.0274 0.0404 51 -0.678 0.9051
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E1_VWFA, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . face - word -0.3541 0.0739 35.7 -4.794 <.0001
## exchange . face - word -0.5693 0.0739 35.7 -7.706 <.0001
## top . face - word -0.2930 0.0739 35.7 -3.966 0.0003
## bottom . face - word -0.5799 0.0739 35.7 -7.850 <.0001
## . face intact - exchange 0.1247 0.0535 100.0 2.331 0.0218
## . face intact - top 0.0660 0.0535 100.0 1.233 0.2205
## . face intact - bottom 0.1821 0.0535 100.0 3.402 0.0010
## . face exchange - top -0.0588 0.0535 100.0 -1.098 0.2747
## . face exchange - bottom 0.0573 0.0535 100.0 1.071 0.2866
## . face top - bottom 0.1161 0.0535 100.0 2.170 0.0324
## . word intact - exchange -0.0904 0.0535 100.0 -1.689 0.0943
## . word intact - top 0.1271 0.0535 100.0 2.375 0.0194
## . word intact - bottom -0.0437 0.0535 100.0 -0.817 0.4158
## . word exchange - top 0.2175 0.0535 100.0 4.065 0.0001
## . word exchange - bottom 0.0467 0.0535 100.0 0.872 0.3852
## . word top - bottom -0.1708 0.0535 100.0 -3.193 0.0019
# contrast(emm_uni_anova_E1, interaction = "pairwise") # , adjust = "none"
plot_uni_E1_VWFA <- {
ggplot(data = as.data.frame(emm_anova_E1_VWFA), aes(y = emmean, x = FaceWord, fill = Layout)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(0, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Beta values") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_uni_E1_VWFA
df_mvpa_agg_E1_VWFA <- {
df_mvpa_acc_E1_VWFA %>%
spread(ClassifyPair, Accuracy) %>% # change to table (each row is one subject)
select(-c(ExpCode, ROI, SubjCode, Count)) # remove these columns
}
df_mvpa_agg_E1_VWFA %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## face_intact-word_intact face_intact-face_exchange
## statistic 8.386719 0.4213617
## parameter 17 17
## p.value 9.540292e-08 0.3393853
## conf.int Numeric,2 Numeric,2
## estimate 0.7138889 0.5111111
## null.value 0.5 0.5
## stderr 0.02550329 0.02636953
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## face_top-face_bottom word_intact-word_exchange
## statistic 0.7757383 1.91145
## parameter 17 17
## p.value 0.2242807 0.03647778
## conf.int Numeric,2 Numeric,2
## estimate 0.5222222 0.5611111
## null.value 0.5 0.5
## stderr 0.02864655 0.03197107
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## word_top-word_bottom
## statistic 0.2360883
## parameter 17
## p.value 0.4080925
## conf.int Numeric,2
## estimate 0.5055556
## null.value 0.5
## stderr 0.02353168
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
plot_mvpa_E1_VWFA <- {
ggplot(data = desc_mvpa_acc_E1_VWFA, aes(y = emmean, x = ClassifyPair)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
geom_hline(yintercept = c(0.5, 1), linetype = 5, alpha = 0.5) + # add the line for 0.5 and 1 (y)
scale_y_continuous(expand= c(0, 0), limits = c(0, 1.1), breaks = seq(0, 1, .25)) + # remove the space between columns and x axis
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) + # show x labels in two rows
labs(title = "", x = "Stimuli", y = "Accuracy") + # set the names for main, x and y axises Subjective Responses for E205
geom_text(label = c("***", "", "", "*", ""), color = c(rep("red", 5)), size = 10, nudge_y = 0.15) + # add starts to the significant columns
general_theme
# theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
}
plot_mvpa_E1_VWFA
df_loc_E2 <- {
df_clean_loc %>%
filter(ExpCode == 2) %>%
mutate(SubjCode = as.factor(SubjCode))
}
# nlevels(df_loc_E2$SubjCode) # number of subjects
anova_loc_E2 <- aov_4(Resp ~ Conditions + (Conditions | SubjCode), data = df_loc_E2)
anova_loc_E2
## Anova Table (Type 3 tests)
##
## Response: Resp
## Effect df MSE F ges p.value
## 1 Conditions 2.31, 41.62 0.04 174.98 *** .60 <.0001
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_loc_anova_E2 <- emmeans(anova_loc_E2, ~ Conditions)
emm_loc_anova_E2
## Conditions emmean SE df lower.CL upper.CL
## face 1.545 0.0909 24.8 1.358 1.732
## object 0.779 0.0909 24.8 0.592 0.967
## word 0.318 0.0909 24.8 0.131 0.505
## scrambled 0.499 0.0909 24.8 0.311 0.686
##
## Warning: EMMs are biased unless design is perfectly balanced
## Confidence level used: 0.95
contrast(emm_loc_anova_E2, "pairwise")
## contrast estimate SE df t.ratio p.value
## face - object 0.766 0.0578 54 13.238 <.0001
## face - word 1.227 0.0578 54 21.218 <.0001
## face - scrambled 1.046 0.0578 54 18.093 <.0001
## object - word 0.461 0.0578 54 7.980 <.0001
## object - scrambled 0.281 0.0578 54 4.855 0.0001
## word - scrambled -0.181 0.0578 54 -3.125 0.0147
##
## P value adjustment: tukey method for comparing a family of 4 estimates
lmm_loc_E2 <- lmer(Resp ~ Conditions + (1 | SubjCode), data = df_loc_E2)
summary(lmm_loc_E2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Resp ~ Conditions + (1 | SubjCode)
## Data: df_loc_E2
##
## REML criterion at convergence: 18.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.79802 -0.44250 -0.05595 0.43601 2.03820
##
## Random effects:
## Groups Name Variance Std.Dev.
## SubjCode (Intercept) 0.12514 0.3537
## Residual 0.03177 0.1782
## Number of obs: 76, groups: SubjCode, 19
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.54488 0.09088 24.75836 17.00 3.67e-15 ***
## Conditionsobject -0.76558 0.05783 54.00000 -13.24 < 2e-16 ***
## Conditionsword -1.22706 0.05783 54.00000 -21.22 < 2e-16 ***
## Conditionsscrambled -1.04633 0.05783 54.00000 -18.09 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cndtnsb Cndtnsw
## Condtnsbjct -0.318
## Conditnswrd -0.318 0.500
## Cndtnsscrmb -0.318 0.500 0.500
emm_loc_lmm_E2 <- emmeans(lmm_loc_E2, ~ Conditions)
emm_loc_lmm_E2
## Conditions emmean SE df lower.CL upper.CL
## face 1.545 0.0909 24.8 1.358 1.732
## object 0.779 0.0909 24.8 0.592 0.967
## word 0.318 0.0909 24.8 0.131 0.505
## scrambled 0.499 0.0909 24.8 0.311 0.686
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
contrast(emm_loc_lmm_E2, "pairwise")
## contrast estimate SE df t.ratio p.value
## face - object 0.766 0.0578 54 13.238 <.0001
## face - word 1.227 0.0578 54 21.218 <.0001
## face - scrambled 1.046 0.0578 54 18.093 <.0001
## object - word 0.461 0.0578 54 7.980 <.0001
## object - scrambled 0.281 0.0578 54 4.855 0.0001
## word - scrambled -0.181 0.0578 54 -3.125 0.0147
##
## Degrees-of-freedom method: kenward-roger
## P value adjustment: tukey method for comparing a family of 4 estimates
plot_loc_E2 <- {
ggplot(data = as.data.frame(emm_loc_anova_E2), aes(y = emmean, x = Conditions)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(0, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Neural Responses") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_loc_E2
# only keep data of E2
df_univar_E2 <- {
df_clean_univar %>%
filter(ExpCode == 2) %>%
mutate(FaceWord = factor(FaceWord, levels = wordsOrder),
SubjCode = as.factor(SubjCode))
}
df_univar_agg_E2 <- {
df_univar_agg %>%
filter(ExpCode == 2) %>%
mutate(FaceWord = factor(FaceWord, levels = wordsOrder),
SubjCode = as.factor(SubjCode))
}
# only keep data of E2
df_mvpa_E2 <- {
df_clean_mvpa %>%
filter(ExpCode == 2) %>%
mutate(ClassifyPair = factor(ClassifyPair, levels = pairOrder_E2),
SubjCode = as.factor(SubjCode))
}
df_mvpa_acc_E2 <- {
df_mvpa_acc %>%
filter(ExpCode == 2) %>%
mutate(ClassifyPair = factor(ClassifyPair, levels = pairOrder_E2),
SubjCode = as.factor(SubjCode))
}
desc_mvpa_acc_E2 <- {
desc_mvpa_acc %>%
filter(ExpCode == 2) %>%
mutate(ClassifyPair = factor(ClassifyPair, levels = pairOrder_E2)) %>%
arrange(ExpCode, Hemisphere, ROI, ClassifyPair)
}
label_lFFA_E2 <- label_lFFA[1] # "roi.lh.f20.f-vs-o.label" "roi.lh.f40.f-vs-o.label"
label_rFFA_E2 <- label_rFFA[1] # "roi.rh.f20.f-vs-o.label" "roi.rh.f40.f-vs-o.label"
label_FFA_E2 <- c(label_lFFA_E2, label_rFFA_E2)
The label used for left FFA in Experiment 2 is roi.lh.f20.f-vs-o.label. The label used for right FFA in Experiment 2 is roi.rh.f20.f-vs-o.label.
# only keep data for these two labels
df_univar_E2_FFA <- filter(df_univar_E2, ROI %in% label_FFA_E2)
df_univar_agg_E2_FFA <- filter(df_univar_agg_E2, ROI %in% label_FFA_E2)
df_mvpa_E2_FFA <- filter(df_mvpa_E2, ROI %in% label_FFA_E2)
df_mvpa_acc_E2_FFA <- filter(df_mvpa_acc_E2, ROI %in% label_FFA_E2)
desc_mvpa_acc_E2_FFA <- filter(desc_mvpa_acc_E2, ROI %in% label_FFA_E2)
# subjects used for each hemisphere
# unique(as.character((df_univar_agg_E2_FFA %>% filter(ROI == label_lFFA_E1))$SubjCode))
desc_mvpa_acc_E2_FFA %>%
select(ExpCode, ROI, Count) %>%
distinct()
anova_E2_lFFA <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E2_FFA, ROI == label_lFFA_E2))
anova_E2_lFFA
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 14 0.08 11.02 ** .07 .005
## 2 Layout 2.62, 36.65 0.01 1.03 .003 .38
## 3 FaceWord:Layout 2.72, 38.14 0.02 3.72 * .01 .02
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E2_lFFA <- emmeans(anova_E2_lFFA, ~ FaceWord * Layout)
emm_anova_E2_lFFA %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E2_lFFA, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## Chinese - English -0.174 0.0524 14 -3.320 0.0051
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E2_lFFA, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.01815 0.0279 42 0.650 0.9148
## intact - top 0.04141 0.0279 42 1.484 0.4561
## intact - bottom -0.00143 0.0279 42 -0.051 1.0000
## exchange - top 0.02326 0.0279 42 0.833 0.8383
## exchange - bottom -0.01958 0.0279 42 -0.702 0.8958
## top - bottom -0.04284 0.0279 42 -1.535 0.4262
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E2_lFFA, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . Chinese - English -0.2648 0.0659 31.6 -4.016 0.0003
## exchange . Chinese - English -0.1816 0.0659 31.6 -2.754 0.0097
## top . Chinese - English -0.0515 0.0659 31.6 -0.781 0.4408
## bottom . Chinese - English -0.1975 0.0659 31.6 -2.996 0.0053
## . Chinese intact - exchange -0.0235 0.0430 82.0 -0.546 0.5868
## . Chinese intact - top -0.0653 0.0430 82.0 -1.518 0.1328
## . Chinese intact - bottom -0.0351 0.0430 82.0 -0.816 0.4170
## . Chinese exchange - top -0.0418 0.0430 82.0 -0.972 0.3337
## . Chinese exchange - bottom -0.0116 0.0430 82.0 -0.270 0.7877
## . Chinese top - bottom 0.0302 0.0430 82.0 0.702 0.4845
## . English intact - exchange 0.0598 0.0430 82.0 1.390 0.1683
## . English intact - top 0.1481 0.0430 82.0 3.444 0.0009
## . English intact - bottom 0.0322 0.0430 82.0 0.749 0.4559
## . English exchange - top 0.0883 0.0430 82.0 2.054 0.0431
## . English exchange - bottom -0.0275 0.0430 82.0 -0.641 0.5235
## . English top - bottom -0.1159 0.0430 82.0 -2.695 0.0085
# contrast(emm_uni_anova_E2, interaction = "pairwise") # , adjust = "none"
anova_E2_rFFA <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E2_FFA, ROI == label_rFFA_E2))
anova_E2_rFFA
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 18 0.05 0.36 .002 .56
## 2 Layout 2.21, 39.80 0.02 1.95 .01 .15
## 3 FaceWord:Layout 2.39, 43.11 0.02 1.08 .005 .36
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E2_rFFA <- emmeans(anova_E2_rFFA, ~ FaceWord * Layout)
emm_anova_E2_rFFA %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E2_rFFA, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## Chinese - English 0.0224 0.0376 18 0.596 0.5584
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E2_rFFA, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.05921 0.031 54 1.912 0.2352
## intact - top -0.00952 0.031 54 -0.307 0.9898
## intact - bottom 0.02333 0.031 54 0.753 0.8749
## exchange - top -0.06873 0.031 54 -2.219 0.1309
## exchange - bottom -0.03588 0.031 54 -1.159 0.6552
## top - bottom 0.03285 0.031 54 1.061 0.7146
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E2_rFFA, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . Chinese - English -0.00259 0.0503 47.7 -0.051 0.9592
## exchange . Chinese - English 0.04090 0.0503 47.7 0.813 0.4203
## top . Chinese - English 0.06961 0.0503 47.7 1.384 0.1729
## bottom . Chinese - English -0.01823 0.0503 47.7 -0.362 0.7188
## . Chinese intact - exchange 0.03747 0.0413 106.3 0.908 0.3661
## . Chinese intact - top -0.04562 0.0413 106.3 -1.105 0.2715
## . Chinese intact - bottom 0.03115 0.0413 106.3 0.755 0.4521
## . Chinese exchange - top -0.08309 0.0413 106.3 -2.013 0.0466
## . Chinese exchange - bottom -0.00632 0.0413 106.3 -0.153 0.8786
## . Chinese top - bottom 0.07677 0.0413 106.3 1.860 0.0657
## . English intact - exchange 0.08095 0.0413 106.3 1.961 0.0525
## . English intact - top 0.02658 0.0413 106.3 0.644 0.5210
## . English intact - bottom 0.01551 0.0413 106.3 0.376 0.7079
## . English exchange - top -0.05438 0.0413 106.3 -1.317 0.1905
## . English exchange - bottom -0.06544 0.0413 106.3 -1.586 0.1158
## . English top - bottom -0.01107 0.0413 106.3 -0.268 0.7891
# contrast(emm_uni_anova_E2, interaction = "pairwise") # , adjust = "none"
# add the column of Hemisphere
nRow_E2 <-nrow(as.data.frame(emm_anova_E2_lFFA))
Hemisphere <- c(rep("left", nRow_E2), rep("right", nRow_E2))
desp_uni_E2_FFA <- cbind(Hemisphere, rbind(as.data.frame(emm_anova_E2_lFFA), as.data.frame(emm_anova_E2_rFFA)))
plot_uni_E2_FFA <- {
ggplot(data = desp_uni_E2_FFA, aes(y = emmean, x = FaceWord, fill = Layout)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(-0.2, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Beta values") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_uni_E2_FFA
df_mvpa_agg_E2_FFA <- {
df_mvpa_acc_E2_FFA %>%
spread(ClassifyPair, Accuracy) %>% # change to table (each row is one subject)
select(-c(ExpCode, ROI, SubjCode, Count)) # remove these columns
}
df_mvpa_agg_E2_FFA %>%
filter(Hemisphere == "left") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## Chinese_intact-English_intact Chinese_intact-Chinese_exchange
## statistic 3.370999 0.3729247
## parameter 14 14
## p.value 0.002284515 0.357395
## conf.int Numeric,2 Numeric,2
## estimate 0.6666667 0.51
## null.value 0.5 0.5
## stderr 0.04944132 0.02681506
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## Chinese_top-Chinese_bottom English_intact-English_exchange
## statistic 1 1.304656
## parameter 14 14
## p.value 0.167141 0.1065248
## conf.int Numeric,2 Numeric,2
## estimate 0.5233333 0.5666667
## null.value 0.5 0.5
## stderr 0.02333333 0.05109903
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## English_top-English_bottom
## statistic 1.851874
## parameter 14
## p.value 0.04262365
## conf.int Numeric,2
## estimate 0.59
## null.value 0.5
## stderr 0.04859943
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
df_mvpa_agg_E2_FFA %>%
filter(Hemisphere == "right") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## Chinese_intact-English_intact Chinese_intact-Chinese_exchange
## statistic 7.006318 0.6732291
## parameter 18 18
## p.value 7.674323e-07 0.2546769
## conf.int Numeric,2 Numeric,2
## estimate 0.6131579 0.5184211
## null.value 0.5 0.5
## stderr 0.01615084 0.02736224
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## Chinese_top-Chinese_bottom English_intact-English_exchange
## statistic 2.2723 1.690087
## parameter 18 18
## p.value 0.01778157 0.05412773
## conf.int Numeric,2 Numeric,2
## estimate 0.5631579 0.5578947
## null.value 0.5 0.5
## stderr 0.0277947 0.03425548
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## English_top-English_bottom
## statistic 1.523234
## parameter 18
## p.value 0.07253794
## conf.int Numeric,2
## estimate 0.5421053
## null.value 0.5
## stderr 0.02764202
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
plot_mvpa_E2_FFA <- {
ggplot(data = desc_mvpa_acc_E2_FFA, aes(y = emmean, x = ClassifyPair)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
geom_hline(yintercept = c(0.5, 1), linetype = 5, alpha = 0.5) + # add the line for 0.5 and 1 (y)
scale_y_continuous(expand= c(0, 0), limits = c(0, 1.1), breaks = seq(0, 1, .25)) + # remove the space between columns and x axis
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) + # show x labels in two rows
labs(title = "", x = "Stimuli", y = "Accuracy") + # set the names for main, x and y axises Subjective Responses for E205
geom_text(label = c("**", "", "", "", "*", "***", "", "*", "*", "*"), color = c(rep("red", 8), rep("blue", 2)), size = 10, nudge_y = 0.15) + # add starts to the significant columns
general_theme
# theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
}
plot_mvpa_E2_FFA
label_lFFA1_E2 <- label_lFFA1[1] # "roi.lh.f13.f-vs-o.ffa1.label" "roi.lh.f20.f-vs-o.ffa1.label"
label_rFFA1_E2 <- label_rFFA1[1] # "roi.rh.f13.f-vs-o.ffa1.label"
label_FFA1_E2 <- c(label_lFFA1_E2, label_rFFA1_E2)
The label used for left FFA1 in Experiment 2 is roi.lh.f13.f-vs-o.ffa1.label. The label used for right FFA1 in Experiment 2 is roi.rh.f13.f-vs-o.ffa1.label.
# only keep data for these two labels
df_univar_E2_FFA1 <- filter(df_univar_E2, ROI %in% label_FFA1_E2)
df_univar_agg_E2_FFA1 <- filter(df_univar_agg_E2, ROI %in% label_FFA1_E2)
df_mvpa_E2_FFA1 <- filter(df_mvpa_E2, ROI %in% label_FFA1_E2)
df_mvpa_acc_E2_FFA1 <- filter(df_mvpa_acc_E2, ROI %in% label_FFA1_E2)
desc_mvpa_acc_E2_FFA1 <- filter(desc_mvpa_acc_E2, ROI %in% label_FFA1_E2)
# subjects used for each hemisphere
# unique(as.character((df_univar_agg_E2_FFA1 %>% filter(ROI == label_rFFA1_E1))$SubjCode))
desc_mvpa_acc_E2_FFA1 %>%
select(ExpCode, ROI, Count) %>%
distinct()
anova_E2_lFFA1 <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E2_FFA1, ROI == label_lFFA1_E2))
anova_E2_lFFA1
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 14 0.12 8.34 * .07 .01
## 2 Layout 2.09, 29.30 0.03 4.31 * .02 .02
## 3 FaceWord:Layout 2.33, 32.60 0.03 4.93 * .02 .01
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E2_lFFA1 <- emmeans(anova_E2_lFFA1, ~ FaceWord * Layout)
emm_anova_E2_lFFA1 %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E2_lFFA1, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## Chinese - English -0.182 0.063 14 -2.888 0.0119
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E2_lFFA1, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange -0.10418 0.0345 42 -3.017 0.0216
## intact - top 0.00476 0.0345 42 0.138 0.9990
## intact - bottom -0.02024 0.0345 42 -0.586 0.9357
## exchange - top 0.10894 0.0345 42 3.155 0.0151
## exchange - bottom 0.08394 0.0345 42 2.431 0.0867
## top - bottom -0.02500 0.0345 42 -0.724 0.8869
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E2_lFFA1, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . Chinese - English -0.17659 0.0775 29.4 -2.279 0.0301
## exchange . Chinese - English -0.30815 0.0775 29.4 -3.978 0.0004
## top . Chinese - English -0.03013 0.0775 29.4 -0.389 0.7002
## bottom . Chinese - English -0.21326 0.0775 29.4 -2.753 0.0100
## . Chinese intact - exchange -0.03840 0.0504 83.7 -0.761 0.4487
## . Chinese intact - top -0.06847 0.0504 83.7 -1.357 0.1783
## . Chinese intact - bottom -0.00191 0.0504 83.7 -0.038 0.9699
## . Chinese exchange - top -0.03007 0.0504 83.7 -0.596 0.5527
## . Chinese exchange - bottom 0.03649 0.0504 83.7 0.723 0.4715
## . Chinese top - bottom 0.06656 0.0504 83.7 1.319 0.1906
## . English intact - exchange -0.16996 0.0504 83.7 -3.369 0.0011
## . English intact - top 0.07799 0.0504 83.7 1.546 0.1259
## . English intact - bottom -0.03858 0.0504 83.7 -0.765 0.4466
## . English exchange - top 0.24795 0.0504 83.7 4.915 <.0001
## . English exchange - bottom 0.13139 0.0504 83.7 2.605 0.0109
## . English top - bottom -0.11657 0.0504 83.7 -2.311 0.0233
# contrast(emm_uni_anova_E2, interaction = "pairwise") # , adjust = "none"
anova_E2_rFFA1 <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E2_FFA1, ROI == label_rFFA1_E2))
anova_E2_rFFA1
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 16 0.11 1.17 .009 .30
## 2 Layout 2.08, 33.25 0.04 1.37 .008 .27
## 3 FaceWord:Layout 2.66, 42.50 0.02 0.65 .003 .57
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E2_rFFA1 <- emmeans(anova_E2_rFFA1, ~ FaceWord * Layout)
emm_anova_E2_rFFA1 %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E2_rFFA1, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## Chinese - English 0.0608 0.0563 16 1.081 0.2959
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E2_rFFA1, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.0427 0.0403 48 1.058 0.7162
## intact - top -0.0369 0.0403 48 -0.916 0.7963
## intact - bottom 0.0170 0.0403 48 0.422 0.9744
## exchange - top -0.0796 0.0403 48 -1.975 0.2118
## exchange - bottom -0.0256 0.0403 48 -0.636 0.9198
## top - bottom 0.0540 0.0403 48 1.339 0.5435
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E2_rFFA1, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . Chinese - English 0.04295 0.0712 36.6 0.603 0.5503
## exchange . Chinese - English 0.09302 0.0712 36.6 1.306 0.1997
## top . Chinese - English 0.09567 0.0712 36.6 1.343 0.1875
## bottom . Chinese - English 0.01165 0.0712 36.6 0.164 0.8710
## . Chinese intact - exchange 0.01762 0.0538 94.6 0.328 0.7440
## . Chinese intact - top -0.06329 0.0538 94.6 -1.176 0.2424
## . Chinese intact - bottom 0.03267 0.0538 94.6 0.607 0.5452
## . Chinese exchange - top -0.08091 0.0538 94.6 -1.504 0.1360
## . Chinese exchange - bottom 0.01505 0.0538 94.6 0.280 0.7804
## . Chinese top - bottom 0.09596 0.0538 94.6 1.783 0.0777
## . English intact - exchange 0.06769 0.0538 94.6 1.258 0.2114
## . English intact - top -0.01057 0.0538 94.6 -0.196 0.8447
## . English intact - bottom 0.00137 0.0538 94.6 0.026 0.9797
## . English exchange - top -0.07826 0.0538 94.6 -1.455 0.1491
## . English exchange - bottom -0.06632 0.0538 94.6 -1.233 0.2208
## . English top - bottom 0.01194 0.0538 94.6 0.222 0.8248
# contrast(emm_uni_anova_E2, interaction = "pairwise") # , adjust = "none"
# add the column of Hemisphere
nRow_E2 <-nrow(as.data.frame(emm_anova_E2_lFFA1))
Hemisphere <- c(rep("left", nRow_E2), rep("right", nRow_E2))
desp_uni_E2_FFA1 <- cbind(Hemisphere, rbind(as.data.frame(emm_anova_E2_lFFA1), as.data.frame(emm_anova_E2_rFFA1)))
plot_uni_E2_FFA1 <- {
ggplot(data = desp_uni_E2_FFA1, aes(y = emmean, x = FaceWord, fill = Layout)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(0, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Beta values") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_uni_E2_FFA1
df_mvpa_agg_E2_FFA1 <- {
df_mvpa_acc_E2_FFA1 %>%
spread(ClassifyPair, Accuracy) %>% # change to table (each row is one subject)
select(-c(ExpCode, ROI, SubjCode, Count)) # remove these columns
}
df_mvpa_agg_E2_FFA1 %>%
filter(Hemisphere == "left") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## Chinese_intact-English_intact Chinese_intact-Chinese_exchange
## statistic 3.554647 1.811422
## parameter 14 14
## p.value 0.001585763 0.04578915
## conf.int Numeric,2 Numeric,2
## estimate 0.6733333 0.55
## null.value 0.5 0.5
## stderr 0.04876246 0.02760262
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## Chinese_top-Chinese_bottom English_intact-English_exchange
## statistic 1.234582 1.189271
## parameter 14 14
## p.value 0.1186536 0.1270566
## conf.int Numeric,2 Numeric,2
## estimate 0.53 0.5533333
## null.value 0.5 0.5
## stderr 0.02429972 0.04484541
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## English_top-English_bottom
## statistic 1.350869
## parameter 14
## p.value 0.09908375
## conf.int Numeric,2
## estimate 0.5533333
## null.value 0.5
## stderr 0.03948076
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
df_mvpa_agg_E2_FFA1 %>%
filter(Hemisphere == "right") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## Chinese_intact-English_intact Chinese_intact-Chinese_exchange
## statistic 4.374786 1.07892
## parameter 16 16
## p.value 0.0002356452 0.1483103
## conf.int Numeric,2 Numeric,2
## estimate 0.6470588 0.5411765
## null.value 0.5 0.5
## stderr 0.03361509 0.03816453
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## Chinese_top-Chinese_bottom English_intact-English_exchange
## statistic 1.605324 0.3556434
## parameter 16 16
## p.value 0.06398815 0.3633766
## conf.int Numeric,2 Numeric,2
## estimate 0.5617647 0.5117647
## null.value 0.5 0.5
## stderr 0.03847493 0.03308006
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## English_top-English_bottom
## statistic 2.617503
## parameter 16
## p.value 0.009332387
## conf.int Numeric,2
## estimate 0.5852941
## null.value 0.5
## stderr 0.03258606
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
plot_mvpa_E2_FFA1 <- {
ggplot(data = desc_mvpa_acc_E2_FFA1, aes(y = emmean, x = ClassifyPair)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
geom_hline(yintercept = c(0.5, 1), linetype = 5, alpha = 0.5) + # add the line for 0.5 and 1 (y)
scale_y_continuous(expand= c(0, 0), limits = c(0, 1.1), breaks = seq(0, 1, .25)) + # remove the space between columns and x axis
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) + # show x labels in two rows
labs(title = "", x = "Stimuli", y = "Accuracy") + # set the names for main, x and y axises Subjective Responses for E205
geom_text(label = c("**", "*", "", "", "*", "***", "", "*", "", "**"), color = c(rep("red", 4), "blue", rep("red", 2), "blue", rep("red", 2)), size = 10, nudge_y = 0.15) + # add starts to the significant columns
general_theme
# theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
}
plot_mvpa_E2_FFA1
label_lFFA2_E2 <- label_lFFA2[1] # "roi.lh.f13.f-vs-o.ffa2.label"
label_rFFA2_E2 <- label_rFFA2[1] # "roi.rh.f20.f-vs-o.ffa2.label" "roi.rh.f40.f-vs-o.ffa2.label"
label_FFA2_E2 <- c(label_lFFA2_E2, label_rFFA2_E2)
The label used for left FFA2 in Experiment 1 is roi.lh.f13.f-vs-o.ffa2.label. The label used for right FFA2 in Experiment 1 is roi.rh.f20.f-vs-o.ffa2.label.
# only keep data for these two labels
df_univar_E2_FFA2 <- filter(df_univar_E2, ROI %in% label_FFA2_E2)
df_univar_agg_E2_FFA2 <- filter(df_univar_agg_E2, ROI %in% label_FFA2_E2)
df_mvpa_E2_FFA2 <- filter(df_mvpa_E2, ROI %in% label_FFA2_E2)
df_mvpa_acc_E2_FFA2 <- filter(df_mvpa_acc_E2, ROI %in% label_FFA2_E2)
desc_mvpa_acc_E2_FFA2 <- filter(desc_mvpa_acc_E2, ROI %in% label_FFA2_E2)
# subjects used for each hemisphere
unique(as.character((df_univar_agg_E2_FFA2 %>% filter(ROI == label_rFFA2_E1))$SubjCode))
## [1] "facewordN01_self" "facewordN02_self" "facewordN03_self"
## [4] "facewordN05_self" "facewordN06_self" "facewordN07_self"
## [7] "facewordN08_self" "facewordN09_self" "facewordN10_self"
## [10] "facewordN11_self" "facewordN12_self" "facewordN13_self"
## [13] "facewordN14_self" "facewordN15_self" "facewordN16_self"
## [16] "facewordN17_self" "facewordN18_self" "facewordN19_self"
## [19] "facewordN20_self"
desc_mvpa_acc_E2_FFA2 %>%
select(ExpCode, ROI, Count) %>%
distinct()
anova_E2_lFFA2 <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E2_FFA2, ROI == label_lFFA2_E2))
anova_E2_lFFA2
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 19 0.08 23.22 *** .12 .0001
## 2 Layout 2.68, 50.87 0.01 1.42 .004 .25
## 3 FaceWord:Layout 2.85, 54.19 0.02 4.16 * .02 .01
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E2_lFFA2 <- emmeans(anova_E2_lFFA2, ~ FaceWord * Layout)
emm_anova_E2_lFFA2 %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E2_lFFA2, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## Chinese - English -0.212 0.0439 19 -4.819 0.0001
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E2_lFFA2, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange -0.0106 0.0253 57 -0.417 0.9753
## intact - top 0.0196 0.0253 57 0.776 0.8649
## intact - bottom -0.0315 0.0253 57 -1.245 0.6010
## exchange - top 0.0302 0.0253 57 1.194 0.6334
## exchange - bottom -0.0210 0.0253 57 -0.828 0.8410
## top - bottom -0.0512 0.0253 57 -2.022 0.1922
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E2_lFFA2, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . Chinese - English -0.28733 0.057 46.6 -5.042 <.0001
## exchange . Chinese - English -0.26178 0.057 46.6 -4.594 <.0001
## top . Chinese - English -0.09498 0.057 46.6 -1.667 0.1023
## bottom . Chinese - English -0.20274 0.057 46.6 -3.558 0.0009
## . Chinese intact - exchange -0.02334 0.039 111.3 -0.599 0.5505
## . Chinese intact - top -0.07654 0.039 111.3 -1.964 0.0520
## . Chinese intact - bottom -0.07381 0.039 111.3 -1.894 0.0608
## . Chinese exchange - top -0.05320 0.039 111.3 -1.365 0.1749
## . Chinese exchange - bottom -0.05047 0.039 111.3 -1.295 0.1979
## . Chinese top - bottom 0.00273 0.039 111.3 0.070 0.9443
## . English intact - exchange 0.00221 0.039 111.3 0.057 0.9548
## . English intact - top 0.11582 0.039 111.3 2.972 0.0036
## . English intact - bottom 0.01079 0.039 111.3 0.277 0.7825
## . English exchange - top 0.11360 0.039 111.3 2.915 0.0043
## . English exchange - bottom 0.00857 0.039 111.3 0.220 0.8263
## . English top - bottom -0.10503 0.039 111.3 -2.695 0.0081
# contrast(emm_uni_anova_E2, interaction = "pairwise") # , adjust = "none"
anova_E2_rFFA2 <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E2_FFA2, ROI == label_rFFA2_E2))
anova_E2_rFFA2
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 18 0.03 0.66 .003 .43
## 2 Layout 2.27, 40.78 0.02 1.23 .008 .31
## 3 FaceWord:Layout 2.34, 42.17 0.02 0.84 .005 .46
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E2_rFFA2 <- emmeans(anova_E2_rFFA2, ~ FaceWord * Layout)
emm_anova_E2_rFFA2 %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E2_rFFA2, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## Chinese - English 0.0235 0.029 18 0.811 0.4277
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E2_rFFA2, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange 0.052371 0.0299 54 1.753 0.3069
## intact - top 0.010039 0.0299 54 0.336 0.9868
## intact - bottom 0.009385 0.0299 54 0.314 0.9891
## exchange - top -0.042331 0.0299 54 -1.417 0.4943
## exchange - bottom -0.042985 0.0299 54 -1.439 0.4810
## top - bottom -0.000654 0.0299 54 -0.022 1.0000
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E2_rFFA2, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . Chinese - English -0.00874 0.0445 61.9 -0.196 0.8450
## exchange . Chinese - English 0.03981 0.0445 61.9 0.894 0.3746
## top . Chinese - English 0.06610 0.0445 61.9 1.485 0.1426
## bottom . Chinese - English -0.00301 0.0445 61.9 -0.068 0.9463
## . Chinese intact - exchange 0.02809 0.0406 107.3 0.691 0.4909
## . Chinese intact - top -0.02738 0.0406 107.3 -0.674 0.5020
## . Chinese intact - bottom 0.00652 0.0406 107.3 0.160 0.8728
## . Chinese exchange - top -0.05548 0.0406 107.3 -1.365 0.1752
## . Chinese exchange - bottom -0.02157 0.0406 107.3 -0.531 0.5967
## . Chinese top - bottom 0.03390 0.0406 107.3 0.834 0.4061
## . English intact - exchange 0.07665 0.0406 107.3 1.886 0.0620
## . English intact - top 0.04746 0.0406 107.3 1.168 0.2455
## . English intact - bottom 0.01225 0.0406 107.3 0.301 0.7637
## . English exchange - top -0.02919 0.0406 107.3 -0.718 0.4743
## . English exchange - bottom -0.06440 0.0406 107.3 -1.584 0.1161
## . English top - bottom -0.03521 0.0406 107.3 -0.866 0.3883
# contrast(emm_uni_anova_E2, interaction = "pairwise") # , adjust = "none"
# add the column of Hemisphere
nRow_E2 <-nrow(as.data.frame(emm_anova_E2_lFFA2))
Hemisphere <- c(rep("left", nRow_E2), rep("right", nRow_E2))
desp_uni_E2_FFA2 <- cbind(Hemisphere, rbind(as.data.frame(emm_anova_E2_lFFA2), as.data.frame(emm_anova_E2_rFFA2)))
plot_uni_E2_FFA2 <- {
ggplot(data = desp_uni_E2_FFA2, aes(y = emmean, x = FaceWord, fill = Layout)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(-0.1, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Beta values") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_uni_E2_FFA2
df_mvpa_agg_E2_FFA2 <- {
df_mvpa_acc_E2_FFA2 %>%
spread(ClassifyPair, Accuracy) %>% # change to table (each row is one subject)
select(-c(ExpCode, ROI, SubjCode, Count)) # remove these columns
}
df_mvpa_agg_E2_FFA2 %>%
filter(Hemisphere == "left") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## Chinese_intact-English_intact Chinese_intact-Chinese_exchange
## statistic 3.838865 1.067091
## parameter 19 19
## p.value 0.0005535313 0.1496514
## conf.int Numeric,2 Numeric,2
## estimate 0.655 0.5275
## null.value 0.5 0.5
## stderr 0.04037652 0.02577101
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## Chinese_top-Chinese_bottom English_intact-English_exchange
## statistic 2.703274 2.352596
## parameter 19 19
## p.value 0.007044696 0.01478635
## conf.int Numeric,2 Numeric,2
## estimate 0.55 0.5775
## null.value 0.5 0.5
## stderr 0.01849609 0.03294233
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## English_top-English_bottom
## statistic 1.643008
## parameter 19
## p.value 0.05841403
## conf.int Numeric,2
## estimate 0.5675
## null.value 0.5
## stderr 0.0410832
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
df_mvpa_agg_E2_FFA2 %>%
filter(Hemisphere == "right") %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## Chinese_intact-English_intact Chinese_intact-Chinese_exchange
## statistic 2.616885 0.4170288
## parameter 18 18
## p.value 0.008733803 0.3407944
## conf.int Numeric,2 Numeric,2
## estimate 0.5631579 0.5105263
## null.value 0.5 0.5
## stderr 0.02413477 0.02524122
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## Chinese_top-Chinese_bottom English_intact-English_exchange
## statistic 0.6909462 1.092107
## parameter 18 18
## p.value 0.2492069 0.1445942
## conf.int Numeric,2 Numeric,2
## estimate 0.5236842 0.5368421
## null.value 0.5 0.5
## stderr 0.03427794 0.03373489
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## English_top-English_bottom
## statistic 2.10448
## parameter 18
## p.value 0.02482625
## conf.int Numeric,2
## estimate 0.5605263
## null.value 0.5
## stderr 0.0287607
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
plot_mvpa_E2_FFA2 <- {
ggplot(data = desc_mvpa_acc_E2_FFA2, aes(y = emmean, x = ClassifyPair)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
geom_hline(yintercept = c(0.5, 1), linetype = 5, alpha = 0.5) + # add the line for 0.5 and 1 (y)
scale_y_continuous(expand= c(0, 0), limits = c(0, 1.1), breaks = seq(0, 1, .25)) + # remove the space between columns and x axis
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) + # show x labels in two rows
labs(title = "", x = "Stimuli", y = "Accuracy") + # set the names for main, x and y axises Subjective Responses for E205
geom_text(label = c("***", "", "**", "*", "*", "**", "", "", "", "*"), color = c(rep("red", 4), "blue", rep("red", 5)), size = 10, nudge_y = 0.15) + # add starts to the significant columns
general_theme
# theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
}
plot_mvpa_E2_FFA2
label_VWFA_E2 <- label_lVWFA[1] # "roi.lh.f13.w-vs-o.label"
The label used for (left) VWFA in Experiment 1 is roi.lh.f13.w-vs-o.label.
# only keep data for these two labels
df_univar_E2_VWFA <- filter(df_univar_E2, ROI %in% label_VWFA_E2)
df_univar_agg_E2_VWFA <- filter(df_univar_agg_E2, ROI %in% label_VWFA_E2)
df_mvpa_E2_VWFA <- filter(df_mvpa_E2, ROI %in% label_VWFA_E2)
df_mvpa_acc_E2_VWFA <- filter(df_mvpa_acc_E2, ROI %in% label_VWFA_E2)
desc_mvpa_acc_E2_VWFA <- filter(desc_mvpa_acc_E2, ROI %in% label_VWFA_E2)
# subjects used for each hemisphere
# unique(as.character((df_univar_agg_E2_VWFA %>% filter(ROI == label_VWFA_E2))$SubjCode))
desc_mvpa_acc_E2_VWFA %>%
select(ExpCode, ROI, Count) %>%
distinct()
anova_E2_VWFA <- aov_4(meanResp ~ FaceWord * Layout + (1 + FaceWord * Layout | SubjCode),
data = filter(df_univar_agg_E2_VWFA, ROI == label_VWFA_E2))
anova_E2_VWFA
## Anova Table (Type 3 tests)
##
## Response: meanResp
## Effect df MSE F ges p.value
## 1 FaceWord 1, 13 0.24 31.76 *** .24 <.0001
## 2 Layout 2.49, 32.43 0.02 4.93 ** .009 .009
## 3 FaceWord:Layout 2.06, 26.78 0.03 5.53 ** .01 .009
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
emm_anova_E2_VWFA <- emmeans(anova_E2_VWFA, ~ FaceWord * Layout)
emm_anova_E2_VWFA %>%
as.data.frame() %>%
arrange(FaceWord)
contrast(emmeans(emm_anova_E2_VWFA, ~ FaceWord), "pairwise")
## contrast estimate SE df t.ratio p.value
## Chinese - English -0.526 0.0934 13 -5.636 0.0001
##
## Results are averaged over the levels of: Layout
contrast(emmeans(emm_anova_E2_VWFA, ~ Layout), "pairwise") # , adjust = "none"
## contrast estimate SE df t.ratio p.value
## intact - exchange -0.0730 0.0317 39 -2.298 0.1160
## intact - top 0.0127 0.0317 39 0.401 0.9779
## intact - bottom -0.0851 0.0317 39 -2.681 0.0502
## exchange - top 0.0857 0.0317 39 2.699 0.0482
## exchange - bottom -0.0122 0.0317 39 -0.383 0.9806
## top - bottom -0.0978 0.0317 39 -3.082 0.0189
##
## Results are averaged over the levels of: FaceWord
## P value adjustment: tukey method for comparing a family of 4 estimates
contrast(emm_anova_E2_VWFA, "pairwise", simple = "each", combine = TRUE, adjust = "none")
## Layout FaceWord contrast estimate SE df t.ratio p.value
## intact . Chinese - English -0.5735 0.1035 19.3 -5.540 <.0001
## exchange . Chinese - English -0.5593 0.1035 19.3 -5.404 <.0001
## top . Chinese - English -0.3488 0.1035 19.3 -3.370 0.0032
## bottom . Chinese - English -0.6231 0.1035 19.3 -6.020 <.0001
## . Chinese intact - exchange -0.0800 0.0484 76.5 -1.655 0.1021
## . Chinese intact - top -0.0996 0.0484 76.5 -2.059 0.0429
## . Chinese intact - bottom -0.0603 0.0484 76.5 -1.247 0.2161
## . Chinese exchange - top -0.0196 0.0484 76.5 -0.404 0.6870
## . Chinese exchange - bottom 0.0197 0.0484 76.5 0.408 0.6848
## . Chinese top - bottom 0.0393 0.0484 76.5 0.812 0.4193
## . English intact - exchange -0.0659 0.0484 76.5 -1.362 0.1772
## . English intact - top 0.1250 0.0484 76.5 2.585 0.0116
## . English intact - bottom -0.1099 0.0484 76.5 -2.273 0.0258
## . English exchange - top 0.1909 0.0484 76.5 3.947 0.0002
## . English exchange - bottom -0.0440 0.0484 76.5 -0.911 0.3653
## . English top - bottom -0.2350 0.0484 76.5 -4.858 <.0001
# contrast(emm_uni_anova_E2, interaction = "pairwise") # , adjust = "none"
plot_uni_E2_VWFA <- {
ggplot(data = as.data.frame(emm_anova_E2_VWFA), aes(y = emmean, x = FaceWord, fill = Layout)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
scale_y_continuous(expand= c(0, 0), limits = c(-0.2, activationUL), breaks = seq(0, 3, .5)) + # remove the space between columns and x axis
labs(title = "", x = "Stimuli", y = "Beta values") + # set the names for main, x and y axises Subjective Responses for E205
general_theme
}
plot_uni_E2_VWFA
df_mvpa_agg_E2_VWFA <- {
df_mvpa_acc_E2_VWFA %>%
spread(ClassifyPair, Accuracy) %>% # change to table (each row is one subject)
select(-c(ExpCode, ROI, SubjCode, Count)) # remove these columns
}
df_mvpa_agg_E2_VWFA %>%
select(-Hemisphere) %>%
sapply(function(x) t.test(x, mu = 0.5, alternative = "greater")) # apply one-sample t-test to each column separately
## Chinese_intact-English_intact Chinese_intact-Chinese_exchange
## statistic 5.560869 0.4340574
## parameter 13 13
## p.value 4.606895e-05 0.3356818
## conf.int Numeric,2 Numeric,2
## estimate 0.7214286 0.5178571
## null.value 0.5 0.5
## stderr 0.03981906 0.04114005
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## Chinese_top-Chinese_bottom English_intact-English_exchange
## statistic 0.4184306 0.3058189
## parameter 13 13
## p.value 0.3412311 0.3822924
## conf.int Numeric,2 Numeric,2
## estimate 0.5142857 0.5142857
## null.value 0.5 0.5
## stderr 0.03414118 0.04671299
## alternative "greater" "greater"
## method "One Sample t-test" "One Sample t-test"
## data.name "x" "x"
## English_top-English_bottom
## statistic 1.946261
## parameter 13
## p.value 0.03678209
## conf.int Numeric,2
## estimate 0.5928571
## null.value 0.5
## stderr 0.04771053
## alternative "greater"
## method "One Sample t-test"
## data.name "x"
plot_mvpa_E2_VWFA <- {
ggplot(data = desc_mvpa_acc_E2_VWFA, aes(y = emmean, x = ClassifyPair)) + # set the data, varialbes for x and y axises
geom_col(position = "dodge", color = "black", alpha = .7) + # position of columns and countour of columns
facet_grid(Hemisphere ~ .) +
geom_errorbar(mapping = aes(ymin = lower.CL, ymax = upper.CL), linetype = 1, # set the error bar
show.legend = FALSE, width = 0.25, alpha = .5,
position = position_dodge(width=0.9)) +
geom_hline(yintercept = c(0.5, 1), linetype = 5, alpha = 0.5) + # add the line for 0.5 and 1 (y)
scale_y_continuous(expand= c(0, 0), limits = c(0, 1.1), breaks = seq(0, 1, .25)) + # remove the space between columns and x axis
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) + # show x labels in two rows
labs(title = "", x = "Stimuli", y = "Accuracy") + # set the names for main, x and y axises Subjective Responses for E205
geom_text(label = c("***", "", "", "", "*"), color = c(rep("red", 5)), size = 10, nudge_y = 0.15) + # add starts to the significant columns
general_theme
# theme(axis.text.x = element_text(angle = 60, hjust = 1)) +
}
plot_mvpa_E2_VWFA
# rstudioapi::versionInfo()
sessionInfo()
## R version 3.6.1 (2019-07-05)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Mojave 10.14.5
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] emmeans_1.4.2 lmerTest_3.1-0 afex_0.25-1 lme4_1.1-21
## [5] Matrix_1.2-17 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.3
## [9] purrr_0.3.3 readr_1.3.1 tidyr_1.0.0 tibble_2.1.3
## [13] ggplot2_3.2.1 tidyverse_1.2.1
##
## loaded via a namespace (and not attached):
## [1] httr_1.4.1 jsonlite_1.6 splines_3.6.1
## [4] carData_3.0-3 modelr_0.1.5 assertthat_0.2.1
## [7] cellranger_1.1.0 yaml_2.2.0 numDeriv_2016.8-1.1
## [10] pillar_1.4.2 backports_1.1.5 lattice_0.20-38
## [13] glue_1.3.1 digest_0.6.22 rvest_0.3.5
## [16] minqa_1.2.4 colorspace_1.4-1 htmltools_0.4.0
## [19] plyr_1.8.4 pkgconfig_2.0.3 broom_0.5.2
## [22] haven_2.2.0 xtable_1.8-4 mvtnorm_1.0-11
## [25] scales_1.0.0 openxlsx_4.1.3 rio_0.5.16
## [28] generics_0.0.2 car_3.0-5 ellipsis_0.3.0
## [31] withr_2.1.2 lazyeval_0.2.2 pbkrtest_0.4-7
## [34] cli_1.1.0 magrittr_1.5 crayon_1.3.4
## [37] readxl_1.3.1 estimability_1.3 evaluate_0.14
## [40] nlme_3.1-140 MASS_7.3-51.4 xml2_1.2.2
## [43] foreign_0.8-71 tools_3.6.1 data.table_1.12.6
## [46] hms_0.5.2 lifecycle_0.1.0 munsell_0.5.0
## [49] zip_2.0.4 compiler_3.6.1 rlang_0.4.1
## [52] grid_3.6.1 nloptr_1.2.1 rstudioapi_0.10
## [55] rmarkdown_1.16 boot_1.3-22 gtable_0.3.0
## [58] abind_1.4-5 curl_4.2 reshape2_1.4.3
## [61] R6_2.4.0 lubridate_1.7.4 knitr_1.25
## [64] zeallot_0.1.0 stringi_1.4.3 parallel_3.6.1
## [67] Rcpp_1.0.3 vctrs_0.2.0 tidyselect_0.2.5
## [70] xfun_0.10 coda_0.19-3
A work by Haiyang Jin